# Author    :Dun_Hz
# Time      :2025-04-07 11:42


nums=list(map(int, input().split()))
stk=[]
for num in nums:
    while True:
        # 情况1：栈的最后一个元素和num相等
        if stk and stk[-1]==num:
            num+=stk.pop()

        # 情况2：几个元素之和与num相等
        elif len(stk)>=2:
            total = 0
            cnt = 0
            for i in range(len(stk)-1, -1, -1):
                cnt+=1
                total+=stk[i]
                if total==num:
                    num += total
                    for _ in range(cnt):
                        stk.pop()
                    break
                elif total>num:
                    break
        else:
            break
    stk.append(num)

print(" ".join(map(str, stk)))